import urllib
import urllib2
import cookielib
from tracker_config import config

class DictObj(object):
    def __init__(self, d):
        self.__dict__ = d

yconfig = DictObj(config['youtrack'])
gconfig = DictObj(config['gcode'])

def youtrack_login():
    params = urllib.urlencode(config['youtrack'])
    resource = '/rest/user/login'
    cj = cookielib.LWPCookieJar()
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
    urllib2.install_opener(opener)
    req = urllib2.Request(yconfig.url + resource, params)
    handle = urllib2.urlopen(req)
    print handle.read()


